package com.gitee.l0km.codegen.base;

import java.util.Map;

import com.gitee.l0km.codegen.annotations.Service;

public class ServiceInfo implements WebServiceClassConstants {
	private final Service service;
	private final Map<String, Class<?>> genericTypeMap;
	
	public ServiceInfo(Service service) {
		this.service = service;
		genericTypeMap = null == service ? DEFAULT_GENERIC_TYPE_MAP : CodeGenUtils.createMap(service.genericTypes(),
				service.genericTypeClasses(), true);
	}

	/**
	 * @see com.gitee.l0km.codegen.annotations.Service#bridgeType()
	 */
	public Class<?> getBridgeType() {
		return null==service?null:service.bridgeType();
	}

	/**
	 * @see com.gitee.l0km.codegen.annotations.Service#targetType()
	 */
	public Class<?> getTargetType() {
		return null==service?null:service.targetType();
	}

	/**
	 * @see com.gitee.l0km.codegen.annotations.Service#portPrefix()
	 */
	public String getPortPrefix() {
		return null==service?"":service.portPrefix();
	}

	/**
	 * @return genericTypeMap
	 */
	public Map<String, Class<?>> getGenericTypeMap() {
		return genericTypeMap;
	}
	
	public boolean isAnnotationDefined(){
		return service!=null;
	}

	/**
	 * @param typeName
	 * @see java.util.Map#get(java.lang.Object)
	 */
	public Class<?> getType(String typeName) {
		return genericTypeMap.get(typeName);
	}

}
